# 项目定义
project('ibox', 'cpp',
  version: '0.0.1',
  default_options: [
    'cpp_std=c++20',
    'warning_level=3'],
  meson_version: '>=1.0.0')

# 头文件搜索目录
includes = include_directories('include')

# 外部第三方依赖
# threads_dep = dependency('threads')
fmt_dep = dependency('libfmt',
  # 先从系统中找, 没找到fallback到subprojects中找
  fallback: ['fmt', 'fmt_dep'],
  default_options: ['default_library=static'])

nlohmann_json_dep = dependency('libnlohmann_json',
  fallback: ['nlohmann_json', 'nlohmann_json_dep'])

icecream_dep = dependency('icecream-cpp',
  fallback: ['icecream-cpp', 'icecream_dep'])

cmake = import('cmake')
nng_opts = cmake.subproject_options()
nng_opts.add_cmake_defines({
  'CMAKE_POSITION_INDEPENDENT_CODE': true,
  'BUILD_SHARED_LIBS': false,
})
nng_project = cmake.subproject('nng-cmake', options: nng_opts)

message('nng all cmake targets:', nng_project.target_list())
nng_dep = nng_project.dependency('nng')

ibox_dependencies = []
ibox_dependencies += fmt_dep
ibox_dependencies += nlohmann_json_dep
ibox_dependencies += icecream_dep
ibox_dependencies += nng_dep
# ibox_dependencies += threads_dep
# ibox_dependencies += spdlog_dep

# 传递给编译器的参数, 通常是用来控制编译器的行为
ibox_compile_args = []
#ibox_compile_args += '-DNDEBUG'

# C++编译参数
ibox_cpp_args = []

# 链接参数
ibox_link_args = []
# -rdynamic可以让backtrace时显示函数名
ibox_link_args += '-rdynamic'

subdir('src')
subdir('tests')
subdir('example')
